home *** CD-ROM | disk | FTP | other *** search
/ Aminet 7 / Aminet 7 - August 1995.iso / Aminet / text / hyper / ADtoHT2_1.lha / Source.lha / MyLib.lha / startup / AmigaMain.doc < prev    next >
Encoding:
Text File  |  1995-04-10  |  1.6 KB  |  59 lines

  1. AmigaMain                                                            AmigaMain
  2.  
  3.     NAME
  4.     AmigaMain - your main function
  5.  
  6.     SYNOPSIS
  7.     int AmigaMain(void);
  8.     void AmigaMain(void);
  9.  
  10.     #include <Amiga.h>
  11.     struct WBStartupMsg *WorkbenchMessage;
  12.  
  13.     FUNCTION
  14.     AmigaMain() is the function called by the startup code. Upon
  15.     entry, the workbench message has been taken care of, and
  16.     dos.library V37+ and utility.library V37+ have been opened.
  17.  
  18.     If the program is run from workbench, WorkbenchMessage points
  19.     to the workbench startup message.
  20.  
  21.     If WorkbenchMessage==NULL the program was run from a shell. In
  22.     this case, stdin, stdout and stderr are available.
  23.  
  24.     EXAMPLE
  25.     #include <stdio.h>
  26.     #include <Amiga.h>
  27.     int AmigaMain(void)
  28.     {
  29.       if (!WorkbenchMessage)
  30.         {
  31.           printf("Hello World!\n");
  32.         }
  33.       return 0;
  34.     }
  35.  
  36.     NOTE
  37.     There is no command line parser. Use dos.library/ReadArgs().
  38.     There is no automatic library opening. Use OpenLibrary().
  39.  
  40.     NOTE
  41.     Using void AmigaMain(void) is defined, but that doesn't mean
  42.     you don't need to pass a return value to the caller. Using
  43.     void AmigaMain(void) requires you to use exit() to terminate
  44.     the program. However, the compiler cannot enforce this, so it
  45.     is *your* responsibility.
  46.  
  47.     NOTE
  48.     Why is the entry point called AmigaMain() instead of main()?
  49.     1) Type clashes:
  50.           MyLib                     ANSI/ISO C
  51.         int AmigaMain(void);     int main(void);
  52.               ----               int main(int, char **);
  53.         void AmigaMain(void);        ----
  54.     2) GNU-C inserts some special code into your main() function.
  55.        I don't want that to happen.
  56.  
  57.     SEE ALSO
  58.     MyLib/exit()
  59.